﻿#include "pch.h"
// #include "PerspectiveCamera.h"
//
// #include "glm/ext/matrix_transform.hpp"
//
// namespace Engine
// {
// 	PerspectiveCamera::PerspectiveCamera(glm::vec3 pos, glm::vec3 inWorldUp, float inYaw, float inPitch)
// 	{
// 		front = glm::vec3(0.0f, 0.0f, -1.0f);
// 		moveSpeed = SPEED;
// 		mouseSensitivity = SENSITIVITY;
// 		zoom = ZOOM;
// 		position = pos;
// 		worldUp = inWorldUp;
// 		yaw = inYaw;
// 		pitch = inPitch;
// 		UpdateCameraVectors();
// 	}
//
// 	PerspectiveCamera::PerspectiveCamera(float posX, float posY, float posZ, float upX, float upY, float upZ,
// 	                                     float inYaw,
// 	                                     float inPitch)
// 	{
// 		front = glm::vec3(0.0f, 0.0f, -1.0f);
// 		moveSpeed = SPEED;
// 		mouseSensitivity = SENSITIVITY;
// 		zoom = ZOOM;
// 		position = glm::vec3(posX, posY, posZ);
// 		worldUp = glm::vec3(upX, upY, upZ);
// 		yaw = inYaw;
// 		pitch = inPitch;
// 		UpdateCameraVectors();
// 	}
//
// 	void PerspectiveCamera::ProcessKeyboard(CameraMovement direction, float deltaTime)
// 	{
// 		const float velocity = moveSpeed * deltaTime;
// 		if (direction == FORWARD)
// 			position += front * velocity;
// 		if (direction == BACKWARD)
// 			position -= front * velocity;
// 		if (direction == LEFT)
// 			position -= right * velocity;
// 		if (direction == RIGHT)
// 			position += right * velocity;
// 	}
//
// 	void PerspectiveCamera::ProcessMouseMovement(float xOffset, float yOffset, const bool constrainPitch)
// 	{
// 		xOffset *= mouseSensitivity;
// 		yOffset *= mouseSensitivity;
//
// 		yaw += xOffset;
// 		pitch += yOffset;
//
// 		// make sure that when pitch is out of bounds, screen doesn't get flipped
// 		if (constrainPitch)
// 		{
// 			pitch = std::min(pitch, 89.0f);
// 			pitch = std::max(pitch, -89.0f);
// 		}
//
// 		// update Front, Right and Up Vectors using the updated Euler angles
// 		UpdateCameraVectors();
// 	}
//
// 	void PerspectiveCamera::ProcessMouseScroll(const float yOffset)
// 	{
// 		zoom -= static_cast<float>(yOffset);
// 		zoom = std::max(zoom, 1.0f);
// 		zoom = std::min(zoom, 45.0f);
// 	}
//
// 	const glm::mat4& PerspectiveCamera::GetViewMatrix() const
// 	{
// 		return glm::lookAt(position, position + front, up);
// 	}
//
// 	void PerspectiveCamera::UpdateCameraVectors()
// 	{
// 		// calculate the new Front vector
// 		glm::vec3 front = glm::vec3(0.0f, 0.0f, 0.0f);
// 		front.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch));
// 		front.y = sin(glm::radians(pitch));
// 		front.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch));
// 		front = glm::normalize(front);
// 		// also re-calculate the Right and Up vector
// 		right = glm::normalize(glm::cross(front, worldUp));
// 		// normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement.
// 		up = glm::normalize(glm::cross(right, front));
// 	}
// }
